import QtQuick 2.5
import QtQuick.Controls 2.1
import ".."

Rectangle
{
    id: mySwitch
    implicitHeight: 30
    implicitWidth: 100
    radius: height / 2
    property bool isOn: false
    signal clicked()
    color: Common.colorInvalid

    Rectangle
    {
        id: curSelected
        height: parent.height
        width: parent.width / 2
        radius: height / 2
        color: !mySwitch.isOn ? Common.colorText : Common.colorMain
        x: !mySwitch.isOn ? 0 : width
        Behavior on x{PropertyAnimation{duration : 100}}
    }

    MouseArea
    {
        id: noSelected
        anchors.fill: parent
        onClicked:
        {
            GET_UAC.playBeep()
            mySwitch.isOn = !mySwitch.isOn
            mySwitch.clicked()
        }
    }
}
